# include <cstdio>
# include <cstring>
# include <iostream>
# include <algorithm>
# include <queue>
# include <map>
# include <iostream>
#include <ext/hash_map>
using namespace std;
using namespace __gnu_cxx;

# define testin freopen("in.txt", "r", stdin)
# define testout freopen("out.txt", "w", stdout)

# define rep(x) for(int i = 0; i < (x); ++i)
# define clr(x) memset(x, 0, sizeof(x))
# define clrc(x, c) memset(x, 0, (c)*sizeof(x[0]))

typedef unsigned long long int ulli;
typedef long long int lli;

char b[7][7];
int x;
int st;
const int destpos = 12;
const int dest = 0x873DF;
hash_map<int, char> mp;
vector<int> f[27];
queue <int> Q;

const int dx[] = {1,1,2,2,-1,-1,-2,-2};
const int dy[] = {2,-2,1,-1,2,-2,1,-1};

int main()
{
    testin;
    int T;

    rep(5) for (int j = 0; j < 5; ++j) {
        int t = i*5+j;
        for (int k = 0;k < 8; ++k) {
            int ni = i + dx[k];
            int nj = j + dy[k];
            if (0<=ni&&ni<5&&0<=nj&&nj<5) {
                f[t].push_back(ni*5+nj);
            }
        }
    }
    int src = dest + (destpos << 25);
    Q.push(src);
    mp[ src ] = 1;
    int cnt = 1;
    while (!Q.empty()) {
        int tmp = Q.front(); Q.pop();
        int cur = mp[ tmp ];
        if (cur >= 16) break;
        rep(f[tmp >> 25].size()) {
            int npo = f[tmp >> 25][i];
            int t = (tmp & 0x1FFFFFF) & (0x1<<npo);
            int nxx = t ? (tmp & 0x1FFFFFF):((tmp & 0x1FFFFFF)+(0x1<<npo)-(0x1<<(tmp >> 25)));
            int nst = nxx + (npo<<25);
            if (!mp[ nst ]) {
                mp[nst] = cur+1;
                Q.push(nst);
                ++cnt;
            }
        }
    }
    cout << cnt / 1024 << endl;
    cout << (1<<15)/1024 << endl;
    cout << mp.size() / 1024<<endl;
    cout << Q.size()/1024 << endl;
    while (!Q.empty()) Q.pop();

    cin >> T;
    while (T--) {
        rep(5) scanf("%s", b[i]);
        st = 0;
        rep(5) for (int j = 0; j < 5; ++j) {
            int t = j+i*5;
            if (b[i][j]=='*' || b[i][j]=='1') {
                st |= (0x1<<(t));
                if (b[i][j] == '*') x=t;
            }
        }
        int ans = mp[ st+(x<<25) ];
        if (!ans) cout << "Bored!" << endl;
        else cout << ans-1 << endl;
    }
    while(1);
    return 0;
}
